/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "correlation")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Correlation.findAll", query = "SELECT c FROM Correlation c"),
    @NamedQuery(name = "Correlation.findById", query = "SELECT c FROM Correlation c WHERE c.id = :id"),
    @NamedQuery(name = "Correlation.findByDefinitionTime", query = "SELECT c FROM Correlation c WHERE c.definitionTime = :definitionTime"),
    @NamedQuery(name = "Correlation.findByCorrelation", query = "SELECT c FROM Correlation c WHERE c.correlation = :correlation")})
public class Correlation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private String id;
    @Basic(optional = false)
    @Column(name = "DefinitionTime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date definitionTime;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "Correlation")
    private BigDecimal correlation;
    @JoinColumn(name = "Id_GPI_KPI2", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private GpiKpi idGPIKPI2;
    @JoinColumn(name = "Id_GPI_KPI1", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private GpiKpi idGPIKPI1;

    public Correlation() {
    }

    public Correlation(String id) {
        this.id = id;
    }

    public Correlation(String id, Date definitionTime) {
        this.id = id;
        this.definitionTime = definitionTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getDefinitionTime() {
        return definitionTime;
    }

    public void setDefinitionTime(Date definitionTime) {
        this.definitionTime = definitionTime;
    }

    public BigDecimal getCorrelation() {
        return correlation;
    }

    public void setCorrelation(BigDecimal correlation) {
        this.correlation = correlation;
    }

    public GpiKpi getIdGPIKPI2() {
        return idGPIKPI2;
    }

    public void setIdGPIKPI2(GpiKpi idGPIKPI2) {
        this.idGPIKPI2 = idGPIKPI2;
    }

    public GpiKpi getIdGPIKPI1() {
        return idGPIKPI1;
    }

    public void setIdGPIKPI1(GpiKpi idGPIKPI1) {
        this.idGPIKPI1 = idGPIKPI1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Correlation)) {
            return false;
        }
        Correlation other = (Correlation) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.Correlation[ id=" + id + " ]";
    }
    
}
